<?php
	$input_word = $_POST['value'];
	
	require "../../lib/common/dbRoutines.php";
	require '../../lib/dao/WordDao.php';
	require '../../lib/model/Word.php';
	
	/*header('Content-type: text/html; charset=utf-8');	*/
	//$input_word = iconv("UTF-8", "windows-1251", $_POST['value']);
	
	
	$conn = getDbConnection();
	
	$word = new Word();
	$word->value = $input_word;
	$word->complexity = "";
	$word->moderated = false;

	$wordDao = new WordDao($conn);
	
	if($wordDao->exists_word($input_word)) {
		echo "exist";
	} 
	else {
		$wordDao->insert($word);
		echo "ok";
	}
	//echo "ok";
	$wordDao->close_conn();
?>